<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Opens a socket on port to accept connections</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.socket-create-listen" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">socket_create_listen</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">socket_create_listen</span> &mdash; <span class="dc-title">Opens a socket on port to accept connections </span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.socket-create-listen-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>socket_create_listen</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$backlog</code><span class="initializer"> = 128</span></span>
  ] ) : <span class="type">resource</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>socket_create_listen()</strong></span> creates a new socket resource of
   type <strong><code>AF_INET</code></strong> listening on <em class="emphasis">all</em>
   local interfaces on the given port waiting for new connections.
  </p>
  <p class="para">
   This function is meant to ease the task of creating a new socket which
   only listens to accept new connections.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.socket-create-listen-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">port</code></dt>

     <dd>

      <p class="para">
       The port on which to listen on all interfaces.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">backlog</code></dt>

     <dd>

      <p class="para">
       The <code class="parameter">backlog</code> parameter defines the maximum length
       the queue of pending connections may grow to.
       <strong><code>SOMAXCONN</code></strong> may be passed as
       <code class="parameter">backlog</code> parameter, see
       <span class="function"><a href="socket_listen.html" class="function">socket_listen()</a></span> for more information.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.socket-create-listen-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <span class="function"><strong>socket_create_listen()</strong></span> returns a new socket resource
   on success or <strong><code>FALSE</code></strong> on error. The error code can be retrieved with
   <span class="function"><a href="socket_last_error.html" class="function">socket_last_error()</a></span>. This code may be passed to
   <span class="function"><a href="socket_strerror.html" class="function">socket_strerror()</a></span> to get a textual explanation of the
   error.
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.socket-create-listen-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    If you want to create a socket which only listens on a certain
    interface you need to use <span class="function"><a href="socket_create.html" class="function">socket_create()</a></span>,
    <span class="function"><a href="socket_bind.html" class="function">socket_bind()</a></span> and <span class="function"><a href="socket_listen.html" class="function">socket_listen()</a></span>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.socket-create-listen-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="socket_create.html" class="function" rel="rdfs-seeAlso">socket_create()</a> - 创建一个套接字（通讯节点）</span></li>
    <li class="member"><span class="function"><a href="socket_create_pair.html" class="function" rel="rdfs-seeAlso">socket_create_pair()</a> - Creates a pair of indistinguishable sockets and stores them in an array</span></li>
    <li class="member"><span class="function"><a href="socket_bind.html" class="function" rel="rdfs-seeAlso">socket_bind()</a> - 给套接字绑定名字</span></li>
    <li class="member"><span class="function"><a href="socket_listen.html" class="function" rel="rdfs-seeAlso">socket_listen()</a> - Listens for a connection on a socket</span></li>
    <li class="member"><span class="function"><a href="socket_last_error.html" class="function" rel="rdfs-seeAlso">socket_last_error()</a> - Returns the last error on the socket</span></li>
    <li class="member"><span class="function"><a href="socket_strerror.html" class="function" rel="rdfs-seeAlso">socket_strerror()</a> - Return a string describing a socket error</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>